package com.qianmi.demo.controller;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import com.qianmi.demo.enties.Book;
import com.qianmi.demo.jpa.BookJpa;


@RestController
public class DemoController {
	private static Logger logger=LoggerFactory.getLogger(DemoController.class);
	@Autowired
	private BookJpa bookJpa;
	@GetMapping(value="/hello")
	public String hello() {
		logger.info("进入hello方法");
		return "hello boot";
	}
	@GetMapping(value="getAll")
	public List<Book> getAll() {
		return bookJpa.findAll();
	}
	@PostMapping(value="add")
	public Book add(Book book) {
		logger.info("进入添加一个实体");
		bookJpa.save(book);
		return book;
	}
}
